#!/bin/bash
backupdir=/data/backup/mysql
today=`date +%F_%T`
/usr/local/mysql/bin/mysqldump -ubackup -pcicewbackup --single-transaction --routines --all-databases | /bin/gzip > ${backupdir}/${today}.sql.gz
filelist=(`ls -1t ${backupdir} | perl -ne'print if($.>28)'`)
for i in ${filelist[@]};
do rm -rf /data/backup/mysql/$i;
done